#include <stdio.h>
#include <stdlib.h>
#include <sys/queue.h>


typedef struct node {
    int value;
    SLIST_ENTRY(node) field;

} node_t;

SLIST_HEAD(head, node) my_list;

#if 0
typedef struct node {
    int data;
    struct {							 
	    struct node *sle_next;	/* next element */	 
    }field;
} node_t;
#endif


int main() {
    int i, value;
    struct node *ele = NULL;

SLIST_INIT(&my_list);
printf("Init main , list empty %d\r\n", SLIST_EMPTY(&my_list)?1:0);
 
    for (i = 0; i < 5; i++) {
        printf("enter %d elememt:\r\n", i);
        scanf("%d", &value);

        ele = (struct node *)malloc(sizeof(struct node));
        ele->value = value;
        SLIST_INSERT_HEAD(&my_list, ele, field);
    }

    printf("SList content:\r\n");
    SLIST_FOREACH(ele, &my_list, field) {
        printf("%d \r\n", ele->value);
    }


    printf("After main , list empty %d\r\n", SLIST_EMPTY(&my_list)?1:0);

    return 0;
}